*===============================================================================
* Do-file creates "Experimental Dataset: Balance Tests (Treatment = Mobile Salary)"
* Appendix Table A8
*===============================================================================
clear 
set more off

cd "~/Dropbox/VFD/REStat_Native_Files/Stata_Files"
local output "~/Dropbox/VFD/REStat_Native_Files/Stata_Files/Output"

use "cadg_master_treatment_NATIVE.dta", clear


replace salary_afs = salary_afs/1000

gen  X = .
label var X ""
label var age "Age"
label var married "Married"
label var numchildren "Number Children" 
label var pashtun "Pashtun"
label var tenure_month "Tenure (Months)" 
label var salary_afs "Monthly Salary (1000 Afs)"
label var airtime_exp "Monthly Airtime Bill (Afs)"
label var family_trans_share "Family Transfer Share"
label var banked "Formally Banked (=1)"
label var hawala_user "Hawala User"
label var roshan_user "Roshan User"
label var wants_mpaisa "Wants M-Paisa"

ttest age, by(treat_final)
matrix B=[r(mu_1),r(mu_2),r(mu_2) - r(mu_1), r(p) \ r(sd_1), r(sd_2), r(se), .]
matrix colnames B="Cash" "Mobile" "Difference" "p-value" 
matrix rownames B=age "X"


foreach var in married numchildren pashtun tenure_month salary_afs airtime_exp ///
family_trans_share banked hawala_user roshan_user wants_mpaisa {

ttest `var', by(treat_final)
    matrix A=[r(mu_1),r(mu_2),r(mu_2) - r(mu_1), r(p) \ r(sd_1), r(sd_2), r(se), .]
matrix rownames A=`var' "X"
matrix B=B\[A]

}

matrix list B
drop X

mat2txt , matrix(B) saving(`output'/table_a8.txt) title(T-tests of equality - Treatment = Mobile Salary) ///
 note(text) format(%6.3f) replace


